﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TimeCard.Core;

namespace TimeCard
{
    public partial class frmSettingRule : Form
    {
        public frmSettingRule()
        {
            InitializeComponent();
        }

        public UserRule SelectedRule { get; set; }

        private void frmSettingRule_Load(object sender, EventArgs e)
        {
            var rules = ApiService.UserRuleService.GetList();
            comboRule.DataSource = rules;
            if (rules.Count > 0)
            {
                comboRule.SelectedIndex = 0;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (comboRule.SelectedItem == null)
            {
                MessageBox.Show("请选择一个打卡规则");
                return;
            }
            SelectedRule = comboRule.SelectedItem as UserRule;
            this.DialogResult = DialogResult.OK;
        }
    }
}
